//
//  NSDate+DateTime.m
//  FMS
//
//  Created by Steven on 10/11/13.
//  Copyright (c) 2013 QGSVN. All rights reserved.
//

#import "NSDate+DateTime.h"

@implementation NSDate (DateTime)
+ (NSString *)stringFormatTimeDateFromDate:(NSDate *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
//		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"hh:mm a - MMM dd, yyyy"];
    return [dateFormatter stringFromDate:date];
}
+ (NSDate *)dateFormatTimeDateFromString:(NSString *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
//		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"hh:mm a - MMM dd, yyyy"];
    return [dateFormatter dateFromString:date];
}
+ (NSDate *)dateFormatDateDisplayFromString:(NSString *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"MMM dd, yyyy"];
    return [dateFormatter dateFromString:date];
}
+ (NSString *)stringFormatDateDisplayFromDate:(NSDate *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
//		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"MMM dd, yyyy"];
    return [dateFormatter stringFromDate:date];
}
+ (NSString *)stringFormatDateFromDate:(NSDate *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
//		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    return [dateFormatter stringFromDate:date];
}

+ (NSString *)stringFormatDateFullFromDate:(NSDate *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
//		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    return [dateFormatter stringFromDate:date];
}
+ (NSDate *)dateFormatDateFromString:(NSString *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    return [dateFormatter dateFromString:date];
}

+ (NSDate *)dateFormatDateFullFromString:(NSString *)date{
    static NSDateFormatter *dateFormatter = nil;
	if (!dateFormatter) {
//		NSLocale *en_US_POSIX = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
		dateFormatter = [[NSDateFormatter alloc] init];
//		[dateFormatter setLocale:en_US_POSIX];
//		[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
	}
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    return [dateFormatter dateFromString:date];
}
@end
